package com.tc.property.config.impl;

import com.tc.property.config.AbstractConfig;
import com.tc.property.config.handler.IConfigSourceChangedHandler;
import com.tc.property.config.model.ConfigItem;
import com.tc.property.util.Utils;

import java.util.*;
import java.util.Map.Entry;

public class SysEnvConfig extends AbstractConfig {

	public SysEnvConfig(String source) {
		super(source);
	}

	@Override
	public Map<String, ConfigItem> getConfig(List<IConfigSourceChangedHandler> handlers) {
		Map<String, ConfigItem> contextItemMap = new HashMap<String, ConfigItem>();
		Properties props = Utils.getSysProps();

		Set<Entry<Object, Object>> entrySet = props.entrySet();
		for (Entry<Object, Object> entry : entrySet) {
			String key = entry.getKey() + "";
			contextItemMap.put(key, new ConfigItem(key, entry.getValue() + "", source, 0L, System.currentTimeMillis()));
		}
		return contextItemMap;
	}
}
